package com.atguigu.edumsm.service.impl;


import com.atguigu.edumsm.service.MsmService;
import com.atguigu.edumsm.utils.MailUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.mail.MessagingException;
import java.util.Map;

@Service
public class MsmServiceImpl implements MsmService {

    //发送短信的方法
    @Override
    public boolean send(Map<String, Object> param, String phone) {
        if (StringUtils.isEmpty(phone)) return false;

        try {
            System.out.println(param.get("code"));
            MailUtil.send_mail(phone, "您的验证码为：" + param.get("code"));
            System.out.println("邮件发送成功!");
            return true;
        } catch (MessagingException e) {
            e.printStackTrace();
            return false;
        }

    }
}
